from configparser import ConfigParser

# from tools import File
from tools.yaml_reader import File


class IniReader(File):
    def __init__(self, ini_path: str, section: str = "sit"):
        super(IniReader, self).__init__(ini_path)
        self._data = {}
        self._section = section.lower()
        self._parser = ConfigParser()

    @property
    def data(self):
        if not self._data:
            self._parser.read(self._file_path, encoding="utf-8")
            for k, v in self._parser.items(self._section):
                self._data[k] = int(v) if k in ("port", "maxsize", "minsize") else v

            return self._data


if __name__ == "__main__":
    ini = IniReader(r"F:\project\dimi_web_auto_test_v1\config\database.ini").data
    print(ini)
